#!/bin/bash

#判断pod状态
kubectl get pod -n kubernetes-dashboard |grep -v STATUS |grep -v Running &> /dev/null
if [ $? = 0 ]; then
	echo -e "\033[41;30m [Error]: Dashboard pod is not Running! \033[0m"
	exit
fi
#改为nodeip
kubectl patch svc kubernetes-dashboard -p '{"spec":{"type":"NodePort"}}' -n kubernetes-dashboard

#部署dashboard-adminuser.yaml
kubectl apply -f dashboard-adminuser.yaml

#查看token
echo ----------token----------
kubectl -n kubernetes-dashboard get secret $(kubectl -n kubernetes-dashboard get sa/admin-user -o jsonpath="{.secrets[0].name}") -o go-template="{{.data.token | base64decode}}"
echo

#查看dashboard的svc端口
echo ----------svc port----------
kubectl get svc -n kubernetes-dashboard |grep kubernetes-dashboard